package cn.wolfcode.wolf2w.controller;

import cn.wolfcode.wolf2w.domain.*;
import cn.wolfcode.wolf2w.service.*;
import cn.wolfcode.wolf2w.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.awt.*;
import java.util.List;

/**
 * Created by 甘静斌 on 2020-08-11 21:19
 */
@RestController
@RequestMapping("destinations")
public class DestinationController {

    @Autowired
    private IRegionService regionService;

    @Autowired
    private IDestinationService destinationService;

    @Autowired
    private IStrategyCatalogService strategyCatalogService;

    @Autowired
    private IStrategyService strategyService;

    @Autowired
    private ITravelService travelService;

    /**
     * 前端热门区域展现
     * @return
     */
    @GetMapping("/hotRegion")
    public Object hotRegion(){

        List<Region> list =  regionService.findByIshot();
        return JsonResult.success(list);
    }

    /**
     * 前端热门目的地
     * @param regionId
     * @return
     */
    @GetMapping("/search")
    public Object search(String regionId){

        List<Destination> list = destinationService.queryDestByRegionId(regionId);
        return JsonResult.success(list);
    }

    /**
     * 前后端分离
     * 攻略明细操作
     * 吐司列表
     * @param destId
     * @return
     */
    @GetMapping("/toasts")
    public Object toasts(String destId){

        List<Destination> toasts = destinationService.findToasts(destId);
        return JsonResult.success(toasts);
    }

    /**
     * 目的地下所有攻略分类
     * @param destId
     * @return
     */
    @GetMapping("/catalogs")
    public Object catalogs(String destId){

        List<StrategyCatalog> list = strategyCatalogService.queryByCatalogs(destId);
        return JsonResult.success(list);
    }

    /**
     * 攻略点击量前3
     * @param destId
     * @return
     */
    @GetMapping("/strategies/viewnumTop3")
    public Object viewnumTop3(String destId){


        List<Strategy> list = strategyService.queryByViewnum(destId);
        return JsonResult.success(list);
    }

    @GetMapping("/list")
    public Object list(){

        List<Destination> list = destinationService.list();
        return JsonResult.success(list);
    }

    ///destinations/travels/viewnumTop3

    @GetMapping("/travels/viewnumTop3")
    public Object viewnumTop(String destId){

        List<Travel> list = travelService.queryByDestId(destId);
        return JsonResult.success(list);
    }
}
